package com.bestom.videoplay.callback;

import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import com.bestom.videoplay.MediaApplication;

public class ScanCallback implements BluetoothAdapter.LeScanCallback {

    public String blueAddress;
    @Override
    public void onLeScan(BluetoothDevice bluetoothDevice, int i, byte[] bytes) {
        if (blueAddress == null || !blueAddress.equals(bluetoothDevice.getAddress())){
            String blueName = "P12-SE";
            if (bluetoothDevice.getName() != null && bluetoothDevice.getName().equals(blueName)){
                stopScan();
                MediaApplication.getApplication().setmBluetoothDevice(bluetoothDevice);
                blueAddress = bluetoothDevice.getAddress();
            }
        }
    }

    private void stopScan(){
        MediaApplication.getApplication().getmBluetoothAdapter().stopLeScan(this);
    }
}
